<?php

session_start();
require '../../Modele/Recherche/RQ_recherche.php';
require'../Erreurs.php';

$search = explode(" ", htmlspecialchars($_POST['description']));

$sear = new rechercher();
$res = $sear->recher($search);


if (!empty($res) && $res != null) {
    $_SESSION['res'] = $res;
    header('location: ../../Vue/recherche.php');
    exit;
} else {
    Erreurs::Gerer_erreurs(7);
    header("location:/Projetweb/Projet_Web_2013_Client/Vue/recherche.php?msg=" . $_GET['msg']);
}

class rechercher {

    public function recher($search) {


        if (!empty($search)) {
            foreach ($search as $key => $valueS) {
                $resu = rechercher::rech($valueS);
                return $resu;
            }
        } else {

            echo 'champ vide';
        }
    }

    public function rech($valueS) {


        $rqt = new RQ_Recherche();
        $req = $rqt->recherche($valueS);
        $enregistrement = $req->fetchAll(PDO::FETCH_ASSOC);


        return $enregistrement;
    }

}

?>
